import Vue from 'vue'

import 'normalize.css/normalize.css' // A modern alternative to CSS resets

import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
// import locale from 'element-ui/lib/locale/lang/en' // lang i18n

import '@/styles/index.scss' // global css

// import '@/styles/element-variables.scss' // global css
// 打印
import Print from 'vue-print-nb'
Vue.use(Print)

import App from './App'
import store from './store'
import router from './router'
import i18n from './lang'

// import { imgerror } from '@/directives/index'

import '@/icons' // icon
import '@/permission' // permission control

// 不需要模拟接口,mock文件夹也删掉
// /**
//  * If you don't want to use mock-server
//  * you want to use MockJs for mock api
//  * you can execute: mockXHR()
//  *
//  * Currently MockJs will be used in the production environment,
//  * please remove it before going online ! ! !
//  */
// if (process.env.NODE_ENV === 'production') {
//   const { mockXHR } = require('../mock')
//   mockXHR()
// }

// set ElementUI lang to EN
// Vue.use(ElementUI, { locale })
// 如果想要中文版 element-ui，按如下方式声明
// Vue.use(ElementUI)
Vue.use(ElementUI, {
  i18n: (key, value) => i18n.t(key, value)
})

// import request from './utils/request'
// Vue.prototype.request = request

Vue.config.productionTip = false

//  Vue.directive('imgerror', imgerror) //1 单个注册
// for (const key in allDirectives) {
//   Vue.directive(key, allDirectives[key])
// } //2 批量注册
// 指令：包含图片
import * as allDirectives from '@/directives/index'
Object.keys(allDirectives).forEach(key =>
  Vue.directive(key, allDirectives[key])
) // keys方法批量注册

// import PageTools from '@/components/PageTools'
// Vue.component('PageTools', PageTools)
import MyComponents from '@/components/MyComponents'
Vue.use(MyComponents)

import * as filters from '@/filters'
Object.keys(filters).forEach(key => {
  Vue.filter(key, filters[key])
  // key为函数名
  // console.log(key, '1', filters[key])
  // console.log(Object.keys(filters))
})

new Vue({
  // 挂载在#app的容器上
  el: '#app',
  router,
  store,
  i18n,
  render: h => h(App)
})

// 另一种写法
// new Vue({
//   router,
//   store,
//   render: h => h(App)
// }).$mount('#app')
